Optimal. Leaf size=100 \[ \frac {2 a b \tanh ^{-1}(\sin (c+d x))}{d}-\frac {\left (a^2+2 b^2\right ) \cot (c+d x)}{d}-\frac {\left (a^2+b^2\right ) \cot ^3(c+d x)}{3 d}-\frac {2 a b \csc (c+d x)}{d}-\frac {2 a b \csc ^3(c+d x)}{3 d}+\frac {b^2 \tan (c+d x)}{d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.23, antiderivative size = 100, normalized size of antiderivative = 1.00, number of steps
used = 9, number of rules used = 6, integrand size = 21, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.286, Rules used = {3957, 2990,
2701, 308, 213, 459} \begin {gather*} -\frac {\left (a^2+b^2\right ) \cot ^3(c+d x)}{3 d}-\frac {\left (a^2+2 b^2\right ) \cot (c+d x)}{d}-\frac {2 a b \csc ^3(c+d x)}{3 d}-\frac {2 a b \csc (c+d x)}{d}+\frac {2 a b \tanh ^{-1}(\sin (c+d x))}{d}+\frac {b^2 \tan (c+d x)}{d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 213
Rule 308
Rule 459
Rule 2701
Rule 2990
Rule 3957
Rubi steps
\begin {align*} \int \csc ^4(c+d x) (a+b \sec (c+d x))^2 \, dx &=\int (-b-a \cos (c+d x))^2 \csc ^4(c+d x) \sec ^2(c+d x) \, dx\\ &=(2 a b) \int \csc ^4(c+d x) \sec (c+d x) \, dx+\int \left (b^2+a^2 \cos ^2(c+d x)\right ) \csc ^4(c+d x) \sec ^2(c+d x) \, dx\\ &=\frac {\text {Subst}\left (\int \frac {\left (1+x^2\right ) \left (a^2+b^2+b^2 x^2\right )}{x^4} \, dx,x,\tan (c+d x)\right )}{d}-\frac {(2 a b) \text {Subst}\left (\int \frac {x^4}{-1+x^2} \, dx,x,\csc (c+d x)\right )}{d}\\ &=\frac {\text {Subst}\left (\int \left (b^2+\frac {a^2+b^2}{x^4}+\frac {a^2+2 b^2}{x^2}\right ) \, dx,x,\tan (c+d x)\right )}{d}-\frac {(2 a b) \text {Subst}\left (\int \left (1+x^2+\frac {1}{-1+x^2}\right ) \, dx,x,\csc (c+d x)\right )}{d}\\ &=-\frac {\left (a^2+2 b^2\right ) \cot (c+d x)}{d}-\frac {\left (a^2+b^2\right ) \cot ^3(c+d x)}{3 d}-\frac {2 a b \csc (c+d x)}{d}-\frac {2 a b \csc ^3(c+d x)}{3 d}+\frac {b^2 \tan (c+d x)}{d}-\frac {(2 a b) \text {Subst}\left (\int \frac {1}{-1+x^2} \, dx,x,\csc (c+d x)\right )}{d}\\ &=\frac {2 a b \tanh ^{-1}(\sin (c+d x))}{d}-\frac {\left (a^2+2 b^2\right ) \cot (c+d x)}{d}-\frac {\left (a^2+b^2\right ) \cot ^3(c+d x)}{3 d}-\frac {2 a b \csc (c+d x)}{d}-\frac {2 a b \csc ^3(c+d x)}{3 d}+\frac {b^2 \tan (c+d x)}{d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [B] Leaf count is larger than twice the leaf count of optimal. \(259\) vs. \(2(100)=200\).
time = 0.42, size = 259, normalized size = 2.59 \begin {gather*} \frac {\csc ^5\left (\frac {1}{2} (c+d x)\right ) \sec ^3\left (\frac {1}{2} (c+d x)\right ) \left (-3 a^2-14 a b \cos (c+d x)-2 \left (a^2+4 b^2\right ) \cos (2 (c+d x))+6 a b \cos (3 (c+d x))+a^2 \cos (4 (c+d x))+4 b^2 \cos (4 (c+d x))-6 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right ) \sin (2 (c+d x))+6 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right ) \sin (2 (c+d x))+3 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )-\sin \left (\frac {1}{2} (c+d x)\right )\right ) \sin (4 (c+d x))-3 a b \log \left (\cos \left (\frac {1}{2} (c+d x)\right )+\sin \left (\frac {1}{2} (c+d x)\right )\right ) \sin (4 (c+d x))\right )}{96 d \left (-1+\cot ^2\left (\frac {1}{2} (c+d x)\right )\right )} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.10, size = 116, normalized size = 1.16
method | result | size |
derivativedivides | \(\frac {b^{2} \left (-\frac {1}{3 \sin \left (d x +c \right )^{3} \cos \left (d x +c \right )}+\frac {4}{3 \sin \left (d x +c \right ) \cos \left (d x +c \right )}-\frac {8 \cot \left (d x +c \right )}{3}\right )+2 b a \left (-\frac {1}{3 \sin \left (d x +c \right )^{3}}-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {2}{3}-\frac {\left (\csc ^{2}\left (d x +c \right )\right )}{3}\right ) \cot \left (d x +c \right )}{d}\) | \(116\) |
default | \(\frac {b^{2} \left (-\frac {1}{3 \sin \left (d x +c \right )^{3} \cos \left (d x +c \right )}+\frac {4}{3 \sin \left (d x +c \right ) \cos \left (d x +c \right )}-\frac {8 \cot \left (d x +c \right )}{3}\right )+2 b a \left (-\frac {1}{3 \sin \left (d x +c \right )^{3}}-\frac {1}{\sin \left (d x +c \right )}+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+a^{2} \left (-\frac {2}{3}-\frac {\left (\csc ^{2}\left (d x +c \right )\right )}{3}\right ) \cot \left (d x +c \right )}{d}\) | \(116\) |
risch | \(-\frac {4 i \left (3 b a \,{\mathrm e}^{7 i \left (d x +c \right )}-7 b a \,{\mathrm e}^{5 i \left (d x +c \right )}-3 a^{2} {\mathrm e}^{4 i \left (d x +c \right )}-7 a b \,{\mathrm e}^{3 i \left (d x +c \right )}-2 a^{2} {\mathrm e}^{2 i \left (d x +c \right )}-8 b^{2} {\mathrm e}^{2 i \left (d x +c \right )}+3 b a \,{\mathrm e}^{i \left (d x +c \right )}+a^{2}+4 b^{2}\right )}{3 d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right ) \left ({\mathrm e}^{2 i \left (d x +c \right )}-1\right )^{3}}+\frac {2 b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{d}-\frac {2 b a \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{d}\) | \(177\) |
norman | \(\frac {\frac {a^{2}+2 b a +b^{2}}{24 d}-\frac {3 \left (a^{2}+5 b^{2}\right ) \left (\tan ^{4}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{4 d}+\frac {\left (a^{2}-2 b a +b^{2}\right ) \left (\tan ^{8}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{24 d}+\frac {\left (2 a^{2}-7 b a +5 b^{2}\right ) \left (\tan ^{6}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}+\frac {\left (2 a^{2}+7 b a +5 b^{2}\right ) \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )\right )}{6 d}}{\tan \left (\frac {d x}{2}+\frac {c}{2}\right )^{3} \left (\tan ^{2}\left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}-\frac {2 b a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )-1\right )}{d}+\frac {2 b a \ln \left (\tan \left (\frac {d x}{2}+\frac {c}{2}\right )+1\right )}{d}\) | \(198\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.28, size = 112, normalized size = 1.12 \begin {gather*} -\frac {a b {\left (\frac {2 \, {\left (3 \, \sin \left (d x + c\right )^{2} + 1\right )}}{\sin \left (d x + c\right )^{3}} - 3 \, \log \left (\sin \left (d x + c\right ) + 1\right ) + 3 \, \log \left (\sin \left (d x + c\right ) - 1\right )\right )} + b^{2} {\left (\frac {6 \, \tan \left (d x + c\right )^{2} + 1}{\tan \left (d x + c\right )^{3}} - 3 \, \tan \left (d x + c\right )\right )} + \frac {{\left (3 \, \tan \left (d x + c\right )^{2} + 1\right )} a^{2}}{\tan \left (d x + c\right )^{3}}}{3 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 3.29, size = 178, normalized size = 1.78 \begin {gather*} -\frac {6 \, a b \cos \left (d x + c\right )^{3} + 2 \, {\left (a^{2} + 4 \, b^{2}\right )} \cos \left (d x + c\right )^{4} - 8 \, a b \cos \left (d x + c\right ) - 3 \, {\left (a^{2} + 4 \, b^{2}\right )} \cos \left (d x + c\right )^{2} - 3 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (\sin \left (d x + c\right ) + 1\right ) \sin \left (d x + c\right ) + 3 \, {\left (a b \cos \left (d x + c\right )^{3} - a b \cos \left (d x + c\right )\right )} \log \left (-\sin \left (d x + c\right ) + 1\right ) \sin \left (d x + c\right ) + 3 \, b^{2}}{3 \, {\left (d \cos \left (d x + c\right )^{3} - d \cos \left (d x + c\right )\right )} \sin \left (d x + c\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (a + b \sec {\left (c + d x \right )}\right )^{2} \csc ^{4}{\left (c + d x \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 226 vs.
\(2 (96) = 192\).
time = 0.53, size = 226, normalized size = 2.26 \begin {gather*} \frac {a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 2 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} + 48 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) - 48 \, a b \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + 9 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 30 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - \frac {48 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1} - \frac {9 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 30 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 21 \, b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + a^{2} + 2 \, a b + b^{2}}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3}}}{24 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 1.10, size = 182, normalized size = 1.82 \begin {gather*} \frac {{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3\,{\left (a-b\right )}^2}{24\,d}-\frac {\frac {2\,a\,b}{3}-{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^4\,\left (3\,a^2+10\,a\,b+23\,b^2\right )+{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^2\,\left (\frac {8\,a^2}{3}+\frac {28\,a\,b}{3}+\frac {20\,b^2}{3}\right )+\frac {a^2}{3}+\frac {b^2}{3}}{d\,\left (8\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^3-8\,{\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )}^5\right )}+\frac {\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\,\left (\frac {a^2}{8}-\frac {3\,a\,b}{4}+\frac {5\,b^2}{8}+\frac {{\left (a-b\right )}^2}{4}\right )}{d}+\frac {4\,a\,b\,\mathrm {atanh}\left (\mathrm {tan}\left (\frac {c}{2}+\frac {d\,x}{2}\right )\right )}{d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________